var __extends =
    (this && this.__extends) ||
    (function () {
      var i = function (t, a) {
        return (i =
          Object.setPrototypeOf ||
          ({ __proto__: [] } instanceof Array &&
            function (i, t) {
              i.__proto__ = t;
            }) ||
          function (i, t) {
            for (var a in t)
              Object.prototype.hasOwnProperty.call(t, a) && (i[a] = t[a]);
          })(t, a);
      };
      return function (t, a) {
        function e() {
          this.constructor = t;
        }
        if ("function" != typeof a && null !== a)
          throw new TypeError(
            "Class extends value " + String(a) + " is not a constructor or null"
          );
        i(t, a),
          (t.prototype =
            null === a
              ? Object.create(a)
              : ((e.prototype = a.prototype), new e()));
      };
    })(),
  AXRankListView = (function (i) {
    function t(t) {
      var a = i.call(this) || this;
      return (
        (a.onLoadRankListDataFn = {
          caller: a,
          code: 1192,
          method: function (i) {
            if (0 == i.code) {
              if ((a.list_itemwanjia.scrollTo(0), a.currentPage >= 1)) {
                if (0 == i.list.length) return void a.currentPage--;
                for (n = 0; n < i.list.length; n++) {
                  var t = i.list[n];
                  a.listArr.push(t), (a.dataSource = []);
                }
              } else (a.listArr = i.list), (a.dataSource = []);
              (a.isloading = !1),
                (a.label_myRankList.text = i.more),
                (a.label_myRankList.color = "#c30bf1");
              for (var e, n = 0; n < a.listArr.length; n++)
                (e = {
                  label_rankIndex: { text: a.listArr[n].num + "." },
                  label_rankName: {
                    text: a.listArr[n].name + "  " + a.listArr[n].content,
                  },
                }),
                  a.dataSource.push(e);
              a.list_itemwanjia.dataSource = a.dataSource;
            }
          },
        }),
        (a.onLoadFuJiangListDataFn = {
          caller: a,
          code: 1194,
          method: function (i) {
            if (((a.label_myRankList.text = ""), 0 == i.code)) {
              if (a.currentPage >= 1) {
                if (0 == i.list.length) return void a.currentPage--;
                for (n = 0; n < i.list.length; n++) {
                  var t = i.list[n];
                  a.listArr.push(t), (a.dataSource = []);
                }
              } else (a.listArr = i.list), (a.dataSource = []);
              a.isloading = !1;
              for (var e, n = 0; n < a.listArr.length; n++)
                (e = {
                  label_fujiang_index: { text: " " + a.listArr[n].num + "." },
                  label_fujiang_name: {
                    text: a.listArr[n].lvl + "级" + a.listArr[n].name,
                  },
                  button_fujiang_zhugong: { label: "主公" },
                }),
                  a.dataSource.push(e);
              a.list_itemFujiang.dataSource = a.dataSource;
            }
          },
        }),
        (a.onLoadJiaoPaiListDataFn = {
          caller: a,
          code: 1193,
          method: function (i) {
            if (((a.label_myRankList.text = ""), 0 == i.code)) {
              if (a.currentPage >= 1) {
                if (0 == i.list.length) return void a.currentPage--;
                for (n = 0; n < i.list.length; n++) {
                  var t = i.list[n];
                  a.listArr.push(t), (a.dataSource = []);
                }
              } else (a.listArr = i.list), (a.dataSource = []);
              a.isloading = !1;
              for (var e, n = 0; n < a.listArr.length; n++)
                (e = {
                  lable_jiaopai_index: { text: a.listArr[n].num },
                  lable_jiaopai_name: {
                    text:
                      a.listArr[n].name +
                      "( " +
                      a.listArr[n].val +
                      " )  " +
                      a.listArr[n].master,
                  },
                  button_jiaopai_join: { label: "加入" },
                }),
                  a.dataSource.push(e);
              a.list_itemjiaopai.dataSource = a.dataSource;
            }
          },
        }),
        a.btn_rankList_cancle.on(
          Laya.Event.CLICK,
          a,
          a.onCloseRankListDidClickFn
        ),
        a.tab_rankBoard.on(Laya.Event.CLICK, a, a.onTabRankBoardDidClickFn),
        a.tab_rankWanJia.on(Laya.Event.CLICK, a, a.onTabRankItemDidClickFn),
        a.tab_rankJiaoPai.on(Laya.Event.CLICK, a, a.onDidClickJiaoPaiDataFn),
        WebSocketService.addListener(a.onLoadRankListDataFn),
        WebSocketService.addListener(a.onLoadFuJiangListDataFn),
        WebSocketService.addListener(a.onLoadJiaoPaiListDataFn),
        (a.list_itemwanjia.vScrollBarSkin = ""),
        (a.list_itemwanjia.selectEnable = !0),
        a.list_itemwanjia.on(Laya.Event.CLICK, a, a.onDidClickWanJiaDataFn),
        (a.list_itemjiaopai.selectEnable = !0),
        a.list_itemjiaopai.on(
          Laya.Event.CLICK,
          a,
          a.onDidClickJiaoPaiSelectedFn
        ),
        (a.list_itemjiaopai.vScrollBarSkin = ""),
        (a.list_itemFujiang.renderHandler = new Handler(a, a.onJiaoPaiRender)),
        (a.list_itemjiaopai.scrollBar.changeHandler = new Handler(
          a,
          a.onLoadMoreJiaoPaiData
        )),
        (a.list_itemFujiang.selectEnable = !0),
        (a.list_itemFujiang.renderHandler = new Laya.Handler(
          a,
          a.updateFuJiangItem
        )),
        a.list_itemFujiang.on(Laya.Event.CLICK, a, a.onDidClickFuJiangListData),
        (a.list_itemFujiang.vScrollBarSkin = ""),
        a
      );
    }
    return (
      __extends(t, i),
      (t.openView = function (i) {
        return (
          null == this.rankListVC && (this.rankListVC = new t(i)),
          (this.rankListVC.tab_rankBoard.selectedIndex = 0),
          (this.rankListVC.tab_rankJiaoPai.selectedIndex = 0),
          (this.rankListVC.tab_rankWanJia.selectedIndex = 0),
          "jiaopai" == i
            ? ((this.rankListVC.tab_rankBoard.selectedIndex = 2),
              this.rankListVC.initTabItem(2))
            : this.rankListVC.initTabItem(0),
          (this.rankListVC.currentPage = 0),
          this.rankListVC
        );
      }),
      (t.prototype.onLoadMoreJiaoPaiData = function (i) {
        var t = i / this.list_itemjiaopai.scrollBar.max,
          a = new Date(),
          e = !1;
        if (
          (a.getTime() - this.spaceTime >= 3e3 && (e = !0),
          1 == t && 0 == this.isloading && e)
        )
          return (
            (this.isloading = !0),
            this.currentPage++,
            0 == this.tab_rankJiaoPai.selectedIndex ||
              1 == this.tab_rankJiaoPai.selectedIndex ||
              (2 == this.tab_rankJiaoPai.selectedIndex &&
                WebSocketService.send({
                  c: 1193,
                  d: { type: 1, pageNum: this.currentPage },
                })),
            void (this.spaceTime = a.getTime())
          );
      }),
      (t.prototype.onDidClickJiaoPaiSelectedFn = function (i) {
        if (!(i.target.name = ""))
          if (0 == this.tab_rankBoard.selectedIndex);
          else if (1 == this.tab_rankBoard.selectedIndex);
          else if (2 == this.tab_rankBoard.selectedIndex) {
            var t = this.listArr[this.list_itemjiaopai.selectedIndex];
            FactionDetailDialog.openFactionDetailView(t, "xiangqing");
          }
      }),
      (t.prototype.updateFuJiangItem = function (i, t) {
        this.listArr.length > 0 && (this.list_itemFujiang.visible = !0);
        var a = i.getChildByName("label_fujiang_index");
        a.bgColor = t % 2 == 0 ? "#21225f" : null;
      }),
      (t.prototype.onDidClickFuJiangListData = function (i) {
        if ("button_fujiang_zhugong" == i.target.name) {
          var t = this.listArr[this.list_itemFujiang.selectedIndex];
          FriendsDetailDialog.showFriendDialog(t.roleId, !0);
        }
      }),
      (t.prototype.initTabItem = function (i) {
        0 == i
          ? ((this.tab_rankWanJia.visible = !0),
            (this.list_itemwanjia.visible = !0),
            (this.image_rank_wanjia.visible = !0),
            (this.image_rank_fujiang.visible = !1),
            (this.image_rank_jiaopai.visible = !1),
            (this.tab_rankJiaoPai.visible = !1),
            (this.list_itemjiaopai.visible = !1),
            (this.list_itemFujiang.visible = !1),
            WebSocketService.send({
              c: 1192,
              d: { type: 1, myrate: 0, pageNum: 0 },
            }))
          : 1 == i
          ? ((this.tab_rankWanJia.visible = !1),
            (this.list_itemwanjia.visible = !1),
            (this.image_rank_fujiang.visible = !0),
            (this.image_rank_wanjia.visible = !1),
            (this.image_rank_jiaopai.visible = !1),
            (this.tab_rankJiaoPai.visible = !1),
            (this.list_itemjiaopai.visible = !1),
            (this.list_itemFujiang.visible = !0),
            WebSocketService.send({ c: 1194, d: { pageNum: 0 } }))
          : 2 == i &&
            ((this.tab_rankWanJia.visible = !1),
            (this.list_itemwanjia.visible = !1),
            (this.image_rank_jiaopai.visible = !0),
            (this.image_rank_wanjia.visible = !1),
            (this.image_rank_fujiang.visible = !1),
            (this.tab_rankJiaoPai.visible = !0),
            (this.list_itemjiaopai.visible = !0),
            (this.list_itemFujiang.visible = !1),
            WebSocketService.send({ c: 1193, d: { type: 3, pageNum: 0 } }));
      }),
      (t.prototype.onDidClickJiaoPaiDataFn = function (i) {
        var t;
        "item0" == i.target.name
          ? (t = 3)
          : "item1" == i.target.name
          ? (t = 2)
          : "item2" == i.target.name && (t = 1),
          WebSocketService.send({ c: 1193, d: { type: t, pageNum: 0 } });
      }),
      (t.prototype.onTabRankBoardDidClickFn = function (i) {
        "item0" == i.target.name
          ? this.initTabItem(0)
          : "item1" == i.target.name
          ? (this.initTabItem(1), (this.list_itemFujiang.visible = !1))
          : "item2" == i.target.name && this.initTabItem(2);
      }),
      (t.prototype.onTabRankItemDidClickFn = function (i) {
        var t;
        (this.label_myRankList.text = ""),
          "item0" == i.target.name
            ? (t = 1)
            : "item1" == i.target.name
            ? (t = 2)
            : "item2" == i.target.name
            ? (t = 3)
            : "item3" == i.target.name
            ? (t = 4)
            : "item4" == i.target.name
            ? (t = 5)
            : "item5" == i.target.name && (t = 6),
          WebSocketService.send({
            c: 1192,
            d: { type: t, myrate: 0, pageNum: 0 },
          });
      }),
      (t.prototype.onDidClickWanJiaDataFn = function (i) {
        if ("" != i.target.name && 0 == this.tab_rankBoard.selectedIndex) {
          var t = this.list_itemwanjia.selectedIndex,
            a = this.listArr[t];
          FriendsDetailDialog.showFriendDialog(a.id, !0);
        }
      }),
      (t.prototype.onJiaoPaiRender = function (i, t) {
        var a = i.getChildByName("button_jiaopai_join");
        Global.bangpaiID || Global.bangpaiMem
          ? (a.visible = !1)
          : (a.visible = !0);
      }),
      (t.prototype.onCloseRankListDidClickFn = function () {
        this.removeSelf();
      }),
      t
    );
  })(ui.RankListController.AXRankListViewUI);
